package mamikeji.liaowa.ui.activity.right.setting;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;

import mamikeji.liaowa.R;
import mamikeji.liaowa.http_api.HttpApi;
import mamikeji.liaowa.ui.activity.BaseActivity;

public class Set_WebActivity extends BaseActivity {

    private WebView webView_set_web;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set__web);

        int num = getIntent().getIntExtra("set_type",0);

        setTitleLeftBtn();

        webView_set_web = (WebView) findViewById(R.id.webView_set_web);

        WebSettings webSettings = webView_set_web.getSettings();
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        // 设置WebView属性，能够执行JavaScript脚本
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        // 设置可以支持缩放
        webSettings.setSupportZoom(true);

        webView_set_web.setHorizontalScrollBarEnabled(false);//禁止水平滚动
        webView_set_web.setVerticalScrollBarEnabled(true);//允许垂直滚动

        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webView_set_web.setVerticalScrollBarEnabled(false);
        webView_set_web.setVerticalScrollbarOverlay(false);
        webView_set_web.setHorizontalScrollBarEnabled(false);
        webView_set_web.setHorizontalScrollbarOverlay(false);

        switch (num){
            case 1:
                setTitleName(R.string.set_about_help);
                webView_set_web.loadUrl(HttpApi.ROOT_PATH + HttpApi.SET_WEB_help);
                break;
            case 2:
                setTitleName(R.string.set_about_serviceterms);
                webView_set_web.loadUrl(HttpApi.ROOT_PATH + HttpApi.SET_WEB_service);
                break;
            case 3:
                setTitleName(R.string.set_about_appedition);
                webView_set_web.loadUrl(HttpApi.ROOT_PATH + HttpApi.SET_WEB_appedition + getVersionName());
                break;
        }
    }
}
